package ie.lawlor.amvc;

import java.util.HashMap;
import java.util.Map;

/**
 * @author brendan
 */
public class EventMap extends HashMap {

	public EventMap() {
		super();
	}

	public EventMap(Map events) {
		super(events);
	}
	
	public void setEvents(Map events){
		putAll(events);
	}
	
	/**
	 * Flattens maps of maps, where the inner map is also an EventMap. Used
	 * with Spring to allow maps to be built up from parent to child.
	 */
	public Object put(Object key, Object data){
		if (data instanceof EventMap){
			EventMap dataMap = (EventMap)data;
			super.putAll(dataMap);
			return data;
		} else{
			return super.put(key, data);
		}
	}
	
}
